/**
 * Created by Adam on 2017/5/16.
 */
import React from 'react'
import PropTypes from 'prop-types'
import User from './User'

const UserList = ({users, onUserClick}) => (
    <table style={{borderWidth: 0}}>
        <tbody>
        {users.map(user =>
            <User key={user.id} {...user} onClick={() => onUserClick(user.id)} />
        )}
        </tbody>
    </table>
)

UserList.propType = {
    users: PropTypes.arrayOf(PropTypes.shape({
        id: PropTypes.number.isRequired,
        name: PropTypes.string.isRequired,
        age: PropTypes.number.isRequired,
        gender: PropTypes.string.isRequired
    }).isRequired).isRequired,
    onUserClick: PropTypes.func.isRequired
}

export default UserList